package com.main.ok.common;

import java.text.SimpleDateFormat;
import java.util.Date;

public class CommonUtils {
    public static void runTimeStatistics(String bizName, CommonCallback call) {
        Long start = System.currentTimeMillis();
        call.biz();
        Long end = System.currentTimeMillis();
        System.out.println(bizName + " runs time is : " + (end - start));
    }

    public static String getDateyyyyMMddHHmmss(long timestamp) {
        if (0 == timestamp)
            throw new CommonsException("日期格式不合法");
        Date d = new Date(timestamp);
        String s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d);
        return s;
    }
}
